home *** CD-ROM | disk | FTP | other *** search
- /* mp2win.cpp
-
- Interface for maplay written by Jeff Tsay. E-mail address:
- ctsay@pasteur.eecs.berkeley.edu. Basic sound file player with
- file open, command line capability, pause, stop, and MPEG
- properties. Also added play list and seeking functionality. Uses
- threads, so will NOT work on Win32s!
-
- Adapted from the Sounder sample application distributed on the
- Borland C++ CD */
-
- /* Version 1.80 :
-
- Changes since last version:
-
- Seeking calls functions within the args class instead of directly reading
- or writing variables internal to the class.
-
- Tried to signal the thread procedures to terminate themselves so that
- memory will not be lost. However, this does not always work, so after
- a waiting period TerminateThread is called.
-
- Eliminated passing the crc to maplay, instead a dummy crc is used to read
- the header.
-
- Increased the maximum size of the playlist to 512 entries.
-
- Last edit : 02/01/97 */
-
- /* Version 1.81:
-
- MIDI and WAV files with filenames that contain spaces can now be loaded
- and played. This was due to a suggestion by Alexander Grigoriev. */
-
- #define STRICT
- #include <windows.h>
- #include <commctrl.h>
- #include <commdlg.h>
-
- #include "crc.h"
- #include "ibitstr.h"
- #include "header.h"
- #include "mp2win.h"
- #include "args.h"
- #include "str_lib.h"
- #include <fstream.h>
-
- #define _export
- #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
- #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
- #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
-
- #define LIST_SIZE 512
-
- // Argument containers
- MPEG_Args _maplay_args;
- MPEG_Args *maplay_args = &_maplay_args;
- MCI_Args _mci_args;
- MCI_Args *mci_args = &_mci_args;
- Args* args;
-
- // Thread functions
- DWORD maplay(MPEG_Args *);
- DWORD mciplay(MCI_Args *);
-
- // data initialized by first instance
-
- char szAppName[20];
-
- // Data that can be referenced throughout the
- // program but not passed to other instances
-
- char szName[MAX_PATH]; // Name of sound file
- char FileTitle[MAX_PATH];
- char TitleText[64];
- char command[384]; // MCI command string
- char scratch[1024];
- char Buffer[1024]; // MCI response string
- LPSTR PlayList[LIST_SIZE];
-
- OPENFILENAME ofnTemp;
- LPSTR szFilter = "All Readable Files\0*.mp*;*.snd;*.wav;*.mid;*.txt;*.lst\0\
- MPEG Audio Files (*.mp*)\0*.mp*\0DALET Sound Files (*.snd)\0*.snd\0PCM Wave \
- Files (*.wav)\0*.wav\0MIDI Files (*.mid)\0*.mid\0Playlists (*.txt, *.lst)\0\
- *.txt;*.lst\0\All Files (*.*)\0*.*\0";
-
- // Playlist position and size
- int32 Cur_Index = 0;
- int32 Max_Index = 0;
-
- int32 scroll_range = 0;
- // int predecode=0; // not implemented yet
-
- // State variables
- BOOL ListMode = FALSE;
- BOOL MPEG = FALSE;
- BOOL CDMode = FALSE;
- BOOL Repeat = FALSE;
- BOOL CMDLINE = FALSE;
- BOOL paused = FALSE;
- BOOL can_play = FALSE;
- BOOL can_pause = FALSE;
- BOOL can_stop = FALSE;
- BOOL playing = FALSE;
- BOOL scrolling = FALSE;
- enum e_channels mode = both;
-
- // Dummy CRC pointer
- Crc16 *crc;
-
- // WaveOut handle and its address
- HWAVEOUT hwo;
- HWAVEOUT *phwo = &hwo;
-
- // Threads
- HANDLE MPEG_Thread = NULL;
- HANDLE MCI_Thread = NULL;
- DWORD dwThreadId;
-
- HINSTANCE hInst; // hInstance of application
- HWND hWnd; // hWnd of main window
-
- // Buttons
- HWND openbut, playbut, pausebut, stopbut, aboutbut;
- HWND rewbut, ffbut, prevbut, nextbut;
-
- // Track bar
- int32 line_size;
- HWND tracker;
-
- // Status bar
- int32 panes[4]= {68, 213, 273, -1};
- char playlist_filename[MAX_PATH];
- HWND status_bar;
-
- // Menu
- HMENU mainmenu;
-
- HDC hdc;
- DRAWITEMSTRUCT *dis;
-
- // Function prototypes
-
- int32 PASCAL WinMain(HINSTANCE,HINSTANCE,LPSTR,int32);
- void InitSound(HINSTANCE,HINSTANCE,LPSTR,int32);
- void InitSoundFirst(HINSTANCE);
- void InitSoundEvery(HINSTANCE,int32);
-
- // Helper procedures
- BOOL AppFileOpen();
- BOOL file_load();
- void clear_sound();
- void ok_play();
- void no_play();
- void no_stop();
- BOOL reinit_MPEG();
- BOOL reinit_MCI();
- BOOL WaveP(LPSTR);
- BOOL CDAP(LPSTR);
- BOOL ListP(LPSTR);
- LPSTR Proper_Filename(LPSTR s);
- void CDTrack_Number(LPSTR s);
- void DisplayName(LPSTR);
- BOOL MPEG_play();
- BOOL MCI_play();
- BOOL Get_File_List(LPSTR);
- BOOL File_Init();
- void Next_Song();
- void Init_List();
- void no_list();
- char *time_string(int32 ms, char *dest);
- void update_timewin(int32 num);
-
- // Menu procedures
- void file_open();
- void audio_play();
- void audio_pause();
- void audio_stop();
- void audio_properties();
- void gotop_List(int32 n);
- void about();
- void leave();
-
- // Procedure for options dialog box
- void leave_options(HWND hDlg, BOOL save);
-
- LRESULT APIENTRY SounderWndProc(HWND,UINT,WPARAM,LPARAM);
- BOOL WINAPI Options(HWND hDlg, UINT message, WPARAM wParam,
- LPARAM lParam);
-
- int32 APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpszCmdLine, int32 cmdShow)
- {
- MSG msg;
-
- // Go init this application.
- InitSound(hInstance, hPrevInstance,
- lpszCmdLine, cmdShow);
-
- if (lstrlen(lpszCmdLine)>1) {
-
- CMDLINE=TRUE;
-
- if (ListP(lpszCmdLine)) {
-
- SendMessage(hWnd, WM_CMDLINEFILE, 2, (LPARAM) lpszCmdLine);
-
- } else {
-
- if (WaveP(lpszCmdLine))
- SendMessage(hWnd, WM_CMDLINEFILE, 0, (LPARAM) lpszCmdLine);
- else
- SendMessage(hWnd, WM_CMDLINEFILE, 1, (LPARAM) lpszCmdLine);
-
- }
- }
-
- // Get and dispatch messages for this applicaton.
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return(msg.wParam);
- }
-
- #pragma argsused
- void InitSound(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpszCmdLine, int32 cmdShow)
- {
- InitSoundFirst(hInstance);
- InitSoundEvery(hInstance, cmdShow); // initialization for all instances
- }
-
- void InitSoundFirst(HINSTANCE hInstance)
-
- {
- WNDCLASS wcSoundClass;
-
- // Get string from resource with application name.
- LoadString(hInstance, IDS_NAME, (LPSTR) szAppName, 20);
-
- // Define the window class for this application.
- wcSoundClass.lpszClassName = szAppName;
- wcSoundClass.hInstance = hInstance;
- wcSoundClass.lpfnWndProc = SounderWndProc;
- wcSoundClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcSoundClass.hIcon = LoadIcon(hInstance,
- MAKEINTRESOURCE(ICON_MP));
- wcSoundClass.lpszMenuName = MAKEINTRESOURCE(MENU_1);
- wcSoundClass.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH);
- wcSoundClass.style = CS_HREDRAW | CS_VREDRAW;
- wcSoundClass.cbClsExtra = 0;
- wcSoundClass.cbWndExtra = 0;
-
- // Register the class
- RegisterClass(&wcSoundClass);
- }
-
- void InitSoundEvery(HINSTANCE hInstance, int32 cmdShow)
- {
- int32 i;
- for(i=0; i<LIST_SIZE; i++)
- PlayList[i]=NULL;
- Cur_Index=0;
- Max_Index=0;
-
- hInst = hInstance; // save for use by window procs
-
- InitCommonControls();
-
- // Create applications main window.
- hWnd = CreateWindowEx(
- WS_EX_ACCEPTFILES | WS_EX_CONTROLPARENT,
- szAppName, // window class name
- szAppName, // window title
- WS_OVERLAPPED | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU,
- // type of window
- 100, // x window location
- 100, // y
- 310, // cx and size
- 145, // cy
- NULL, // no parent for this window
- NULL, // use the main menu
- hInstance, // who created this window
- NULL); // no parms to pass on
-
-
- // Update display of main window.
- mainmenu=GetMenu(hWnd);
-
- ShowWindow(hWnd, cmdShow);
- UpdateWindow(hWnd);
-
- ofnTemp.lStructSize = sizeof(OPENFILENAME);
- ofnTemp.hwndOwner = hWnd;
- ofnTemp.hInstance = 0;
- ofnTemp.lpstrFilter = (LPSTR)szFilter;
- ofnTemp.lpstrCustomFilter = NULL;
- ofnTemp.nMaxCustFilter = 0;
- ofnTemp.nFilterIndex = 1;
- ofnTemp.lpstrFile = (LPSTR)szName;
- ofnTemp.nMaxFile = sizeof(szName);
- ofnTemp.lpstrFileTitle = FileTitle;
- ofnTemp.nMaxFileTitle = sizeof(FileTitle);
- ofnTemp.lpstrInitialDir = NULL;
- ofnTemp.lpstrTitle = "Open Sound File";
- ofnTemp.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST |
- OFN_HIDEREADONLY | OFN_EXPLORER;
- ofnTemp.nFileOffset = 0;
- ofnTemp.nFileExtension = 0;
- ofnTemp.lpstrDefExt = "MP*";
- ofnTemp.lCustData = 0;
- ofnTemp.lpfnHook = NULL;
- ofnTemp.lpTemplateName = NULL;
- }
-
- BOOL AppFileOpen()
- {
- DWORD Errval;
-
- if (!GetOpenFileName((LPOPENFILENAME) &ofnTemp))
- {
- Errval = CommDlgExtendedError();
- if (Errval != 0) // 0 value means user selected Cancel
- MessageBox(hWnd, "Could not open file.", "Warning", MB_OK | MB_ICONSTOP);
-
- return(FALSE);
- }
-
- return(TRUE);
- }
-
- char *time_string(int32 ms, char *dest)
- {
- int32 i, j, nmlength;
- int32 seconds, minutes;
- char second_str[4];
- char minute_str[4];
-
- minutes = ms / 60000;
- seconds = ms / 1000 - minutes * 60;
-
- my_itoa(minutes, minute_str, 10);
- my_itoa(seconds, second_str, 10);
-
- nmlength = 3 - lstrlen(minute_str);
-
- for (i=0; i < nmlength ; i++)
- dest[i] = '0';
-
- for (i = nmlength, j=0; i<3; i++, j++)
- dest[i] = minute_str[j];
-
- dest[3] = ':';
-
- nmlength = 6 - lstrlen(second_str);
-
- for (i=4; i < nmlength ; i++)
- dest[i] = '0';
-
- for (i=nmlength, j=0; i<6; i++, j++)
- dest[i] = second_str[j];
-
- dest[6]='\0';
-
- return (dest);
- }
-
- void clear_sound()
- {
- scrolling = FALSE;
-
- if (MPEG) {
-
- if (MPEG_Thread) {
-
- SetThreadPriority(MPEG_Thread, THREAD_PRIORITY_HIGHEST);
-
- if (paused) {
-
- paused = FALSE;
- waveOutReset(*phwo);
- waveOutRestart(*phwo);
- ResumeThread(MPEG_Thread);
- }
-
- WaitForSingleObject(maplay_args->mutex, INFINITE);
-
- if (!maplay_args->done) {
- maplay_args->stop = TRUE;
-
- ReleaseMutex(maplay_args->mutex);
-
- if (WaitForSingleObject(MPEG_Thread, 5000) == WAIT_TIMEOUT) {
- TerminateThread(MPEG_Thread, 0);
- waveOutReset(*phwo);
- waveOutClose(*phwo);
- }
- } else {
- ReleaseMutex(maplay_args->mutex);
- }
-
- CloseHandle(MPEG_Thread);
- }
-
- MPEG_Thread = NULL; // ensures next call to clear_sound() will not
- // attempt to kill thread
-
- delete maplay_args->stream;
- maplay_args->stream = NULL;
-
- delete maplay_args->MPEGheader;
- maplay_args->MPEGheader = NULL;
-
- CloseHandle(maplay_args->mutex);
-
- } else {
-
- if (MCI_Thread) {
-
- WaitForSingleObject(mci_args->mutex, INFINITE);
-
- mci_args->stop = TRUE;
- ReleaseMutex(mci_args->mutex);
-
- if(WaitForSingleObject(MCI_Thread, 5000) == WAIT_TIMEOUT)
- TerminateThread(MCI_Thread, 0);
-
- CloseHandle(MCI_Thread);
- }
-
- MCI_Thread = NULL; // ensures next call to clear_sound() will not
- // attempt to kill thread
-
- mciSendString((LPSTR)"stop sounder", NULL, 0, NULL);
- mciSendString((LPSTR)"close sounder", NULL, 0, NULL);
- }
-
- SendMessage(status_bar, SB_SETTEXT, 0, (LPARAM) "Stopped");
- SendMessage(status_bar, SB_SETTEXT, 2, (LPARAM) "000:00");
-
- return;
- }
-
- void ok_play()
- {
- can_play = TRUE;
- can_pause = FALSE;
- playing = FALSE;
- EnableMenuItem(mainmenu,CM_AUDIOPLAY, MF_ENABLED);
- EnableWindow(playbut, TRUE);
- EnableMenuItem(mainmenu,CM_AUDIOPAUSE, MF_GRAYED);
- EnableWindow(pausebut, FALSE);
- return;
- }
-
- void no_play()
- {
- can_play=FALSE;
- can_pause=TRUE;
- can_stop=TRUE;
- playing=TRUE;
- EnableMenuItem(mainmenu,CM_AUDIOPLAY, MF_GRAYED);
- EnableWindow(playbut, FALSE);
- EnableMenuItem(mainmenu,CM_AUDIOPAUSE, MF_ENABLED);
- EnableWindow(pausebut, TRUE);
- EnableMenuItem(mainmenu,CM_AUDIOSTOP, MF_ENABLED);
- EnableWindow(stopbut, TRUE);
- return;
- }
-
- void no_stop()
- {
- can_stop = FALSE;
- EnableMenuItem(mainmenu,CM_AUDIOSTOP, MF_GRAYED);
- EnableWindow(stopbut, FALSE);
- return;
- }
-
- BOOL reinit_MPEG()
- {
- MPEG = TRUE;
- args = maplay_args;
-
- args->hWnd = hWnd;
- args->mutex = CreateMutex(NULL, FALSE, "m");
- args->stop = FALSE;
- args->done = FALSE;
-
- args->position_change = FALSE;
- args->desired_position = 0;
-
- maplay_args->stream = new Ibitstream(szName);
- maplay_args->MPEGheader = new Header;
- maplay_args->phwo = phwo;
- maplay_args->which_c = mode;
- maplay_args->stdout_mode = FALSE;
- maplay_args->use_own_scalefactor = FALSE;
-
- if (!maplay_args->MPEGheader->read_header(maplay_args->stream, &crc)){
- MessageBox(hWnd, "No header found!",
- "File format error", MB_OK | MB_ICONSTOP);
- return(FALSE);
- }
-
- scroll_range = maplay_args->MPEGheader->min_number_of_frames(maplay_args->stream);
- line_size = scroll_range >> 3;
-
- SendMessage(tracker, TBM_SETRANGEMIN, FALSE, 0);
- SendMessage(tracker, TBM_SETRANGEMAX, FALSE, scroll_range);
- SendMessage(tracker, TBM_SETPOS, TRUE, 0);
- SendMessage(tracker, TBM_SETTICFREQ, scroll_range>>4, 1);
- SendMessage(tracker, TBM_SETLINESIZE, 0, line_size);
-
- EnableMenuItem(mainmenu,CM_AUDIOPROPERTIES, MF_ENABLED);
- EnableMenuItem(mainmenu,CM_OPTIONS, MF_ENABLED);
- EnableWindow(tracker, TRUE);
-
- return(TRUE);
- }
-
- BOOL reinit_MCI()
- {
- MPEG = FALSE;
- CDMode = CDAP(szName);
-
- EnableMenuItem(mainmenu,CM_AUDIOPROPERTIES, MF_GRAYED);
- EnableMenuItem(mainmenu,CM_OPTIONS, MF_GRAYED);
-
- lstrcpy(command, "open \"");
- lstrcat(command, CDMode ? "cdaudio" : szName);
- lstrcat(command, "\" alias sounder wait");
- mciSendString ((LPSTR)command, Buffer, 1024, NULL);
- mciSendString("set sounder time format ms wait", Buffer, 1024, NULL);
- mciSendString("status sounder length wait", Buffer, 1024, NULL);
-
- scroll_range = my_atoi(Buffer);
- line_size = scroll_range >> 3;
-
- args = mci_args;
-
- args->hWnd = hWnd;
- args->mutex = CreateMutex(NULL, FALSE, "m");
- args->stop = FALSE;
- args->done = FALSE;
-
- args->position_change = FALSE;
- args->desired_position = 0;
-
- mci_args->playing = FALSE;
-
- SendMessage(tracker, TBM_SETRANGEMIN, FALSE, 0);
- SendMessage(tracker, TBM_SETRANGEMAX, FALSE, scroll_range);
- SendMessage(tracker, TBM_SETPOS, TRUE, 0);
- SendMessage(tracker, TBM_SETTICFREQ, scroll_range >> 4, 1);
- SendMessage(tracker, TBM_SETLINESIZE, 0, line_size);
- EnableWindow(tracker, TRUE);
-
- return (TRUE);
- }
-
-
- BOOL WaveP(LPSTR t)
- // Check if the file is a format the Windows multimedia system supports.
- {
- return ((lstrcmp(t + lstrlen(t)-3, "WAV") == 0) ||
- (lstrcmp(t + lstrlen(t)-3, "wav") == 0) ||
- (lstrcmp(t + lstrlen(t)-3, "MID") == 0) ||
- (lstrcmp(t + lstrlen(t)-3, "mid") == 0) ||
- (lstrcmp(t + lstrlen(t)-3, "CDA") == 0) ||
- (lstrcmp(t + lstrlen(t)-3, "cda") == 0));
- }
-
- BOOL CDAP(LPSTR t)
- {
- return ((lstrcmp(t + lstrlen(t)-3, "CDA") == 0) ||
- (lstrcmp(t + lstrlen(t)-3, "cda") == 0));
- }
-
- BOOL ListP(LPSTR t)
- {
- return ((lstrcmp(t + lstrlen(t)-3, "TXT") == 0) ||
- (lstrcmp(t + lstrlen(t)-3, "txt") == 0) ||
- (lstrcmp(t + lstrlen(t)-3, "LST") == 0) ||
- (lstrcmp(t + lstrlen(t)-3, "lst") == 0)) ;
- }
-
-
- LPSTR Proper_Filename(LPSTR s)
- {
- int32 length = lstrlen(s);
-
- for(int32 i=length; i>=0; --i)
- if (s[i]=='\\')
- return (s+i+1);
- return(s);
- }
-
- void CDTrack_Number(LPSTR s, LPSTR dest)
- {
- int32 length = lstrlen(s);
- int32 chars_to_copy = 1;
- int32 i = length - 5;
-
- while ((s[i]!='k') && (i>=0)) {
- chars_to_copy++;
- i--;
- }
-
- do {
- i++;
- chars_to_copy--;
- } while (s[i]=='0');
-
- lstrcpyn(s, dest, chars_to_copy);
- return;
- }
-
- void DisplayName(LPSTR name)
- {
-
- LoadString(hInst, IDS_NAME, (LPSTR) TitleText, 64);
- lstrcat(TitleText, " - [");
- if (name)
- lstrcat(TitleText, Proper_Filename(name));
- else
- lstrcat(TitleText, FileTitle);
-
- lstrcat(TitleText, "]");
- SetWindowText(hWnd, (LPCTSTR) TitleText);
- return;
- }
-
- BOOL MPEG_play()
- // Assumes stream, MPEGheader are already initialized
- {
- BOOL t;
- MPEG_Thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) maplay,
- maplay_args, 0, &dwThreadId);
- t = SetThreadPriority(MPEG_Thread, THREAD_PRIORITY_ABOVE_NORMAL);
- return(t);
- }
-
- BOOL MCI_play()
- {
- mci_args->playing = TRUE;
-
- if (CDMode) {
- mciSendString("set cdaudio time format tmsf", NULL, 0, NULL);
- mciSendString("play cdaudio from 2 to 3 notify", Buffer, 0, hWnd);
-
- } else {
- mciSendString ((LPSTR)"play sounder notify", Buffer, 1024, hWnd);
- }
-
- MCI_Thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) mciplay,
- mci_args, 0, &dwThreadId);
- return(TRUE);
- }
-
- BOOL Get_File_List(LPSTR listname)
- {
- ifstream f((const char *) listname);
- Cur_Index = 0;
- Max_Index = 0;
-
- while(!(f.bad() || f.eof() || f.fail() || Max_Index>=LIST_SIZE)) {
- PlayList[Max_Index] = new char[MAX_PATH];
- f.getline(PlayList[Max_Index], MAX_PATH, '\n');
- if ((lstrlen(PlayList[Max_Index]) > 1) &&
- (GetFileAttributes(PlayList[Max_Index]) != 0xFFFFFFFF)) {
- Max_Index++;
- } else {
- delete [] PlayList[Max_Index];
- PlayList[Max_Index] = NULL;
- }
- }
-
- f.close();
-
- if (Max_Index > 0) {
- lstrcpy(playlist_filename, "Track 1: ");
- lstrcat(playlist_filename, Proper_Filename(PlayList[0]));
- SendMessage(status_bar,SB_SETTEXT, 1, (LPARAM) playlist_filename);
- return(TRUE);
- } else {
- lstrcpy(scratch, "Unable to open the playlist \"");
- lstrcat(scratch, listname);
- lstrcat(scratch, "\"");
- MessageBox(hWnd, scratch, "Error opening playlist", MB_OK |
- MB_ICONEXCLAMATION);
- return(FALSE);
- }
- }
-
- BOOL File_Init()
- {
- return (WaveP(szName) ? reinit_MCI() : reinit_MPEG());
- }
-
- void Next_Song()
- {
- if (++Cur_Index < Max_Index) {
- lstrcpy(szName, PlayList[Cur_Index]);
- if (File_Init()) {
- ok_play();
- no_stop();
- lstrcpy(playlist_filename, "Track ");
- lstrcat(playlist_filename, my_itoa(Cur_Index + 1, scratch, 10));
- lstrcat(playlist_filename, ": ");
- lstrcat(playlist_filename, Proper_Filename(szName));
- SendMessage(status_bar,SB_SETTEXT, 1,(LPARAM) playlist_filename);
- audio_play();
- }
-
- } else {
- if (CMDLINE)
- leave();
-
- lstrcpy(playlist_filename, "Track 1: ");
- lstrcat(playlist_filename, Proper_Filename(PlayList[0]));
- SendMessage(status_bar,SB_SETTEXT, 1,(LPARAM) playlist_filename);
- SendMessage(status_bar,SB_SETTEXT, 0,(LPARAM) "Ready");
-
- Cur_Index = 0;
- lstrcpy(szName, PlayList[0]);
- if (File_Init()) {
- ok_play();
- no_stop();
- if (Repeat)
- audio_play();
- }
- }
- return;
- }
-
- void Init_List()
- {
- ListMode = TRUE;
- EnableMenuItem(mainmenu,CM_LISTPREV, MF_ENABLED);
- EnableWindow(prevbut, TRUE);
- EnableMenuItem(mainmenu,CM_LISTREPEAT, MF_ENABLED);
- EnableMenuItem(mainmenu,CM_LISTNEXT, MF_ENABLED);
- EnableWindow(nextbut, TRUE);
- return;
- }
-
- void gotop_List(int32 n)
- {
- CMDLINE = FALSE;
- clear_sound();
-
- Cur_Index += n;
- if (Cur_Index >= Max_Index)
- Cur_Index -= Max_Index;
- else if (Cur_Index <= -1)
- Cur_Index += Max_Index;
-
- Next_Song();
- return;
- }
-
- void no_list()
- {
- int32 i;
-
- ListMode = FALSE;
- EnableMenuItem(mainmenu,CM_LISTPREV, MF_GRAYED);
- EnableWindow(prevbut, FALSE);
- EnableMenuItem(mainmenu,CM_LISTREPEAT, MF_GRAYED);
- EnableMenuItem(mainmenu,CM_LISTNEXT, MF_GRAYED);
- EnableWindow(nextbut, FALSE);
-
- SendMessage(status_bar,SB_SETTEXT, 1, NULL);
-
- for(i=0; i<Max_Index; i++) {
- delete [] PlayList[i];
- PlayList[i] = NULL;
- }
-
- Cur_Index = 0;
- Max_Index = 0;
-
- return;
- }
-
- void update_timewin(int32 num)
- {
- if (MPEG)
- SendMessage(status_bar, SB_SETTEXT, 2,
- (LPARAM) time_string(
- (int32) (num * maplay_args->MPEGheader->ms_per_frame()),
- scratch));
- else
- SendMessage(status_bar, SB_SETTEXT, 2,
- (LPARAM) time_string(num, scratch));
-
- return;
- }
-
- BOOL file_load()
- {
- clear_sound();
-
- no_list();
- if (ListP(szName)) {
- if (Get_File_List(szName)) {
- DisplayName(Proper_Filename(szName));
- Init_List();
- lstrcpy(szName, PlayList[0]);
- } else {
- return(FALSE);
- }
-
- if (!File_Init())
- return(FALSE);
-
- } else {
-
- if (!File_Init())
- return(FALSE);
-
- DisplayName(Proper_Filename(szName));
-
- }
-
- ok_play();
- no_stop();
-
- EnableMenuItem(mainmenu,CM_AUDIOREPEAT, MF_ENABLED);
- EnableWindow(rewbut, TRUE);
- EnableMenuItem(mainmenu, CM_AUDIOREWIND, MF_ENABLED);
- EnableWindow(ffbut, TRUE);
- EnableMenuItem(mainmenu, CM_AUDIOFAST_FORWARD, MF_ENABLED);
-
- SendMessage(status_bar, SB_SETTEXT, 0, (LPARAM) "Ready");
- SendMessage(status_bar, SB_SETTEXT, 2, (LPARAM) "000:00");
-
- return(TRUE);
- }
-
-
- void file_open()
- {
- CMDLINE = FALSE;
-
- // clear_sound();
-
- if (AppFileOpen())
- file_load();
-
- return;
- }
-
- void leave()
- {
- clear_sound();
- no_list();
- DestroyWindow(hWnd);
-
- return;
- }
-
- void audio_play()
- {
- if (can_play) {
- no_play();
-
- if (MPEG) {
- if (paused && MPEG_Thread) {
- paused = FALSE;
- waveOutRestart(*phwo);
- ResumeThread(MPEG_Thread);
- } else {
- MPEG_play();
- }
- } else {
- MCI_play();
- }
- SendMessage(status_bar,SB_SETTEXT, 0,(LPARAM) "Playing...");
- }
- return;
- }
-
- void audio_pause()
- {
- if (can_pause) {
-
- can_pause = FALSE;
- paused = TRUE;
- CMDLINE = FALSE;
-
- if (MPEG) {
- SuspendThread(MPEG_Thread);
- waveOutPause(*phwo);
- } else {
- mci_args->playing = FALSE;
- mciSendString ((LPSTR)"pause sounder", NULL, 0, NULL);
- }
- ok_play();
- SendMessage(status_bar, SB_SETTEXT, 0,(LPARAM) "Paused");
- return;
- }
- }
-
- void audio_stop()
- {
- if (can_stop) {
-
- clear_sound();
-
- can_stop = FALSE;
- CMDLINE = FALSE;
- paused = FALSE;
- playing = FALSE;
-
- File_Init();
- ok_play();
- no_stop();
- }
-
- return;
- }
-
- void audio_properties()
- {
- char MPEGinfo[1024];
-
- lstrcpy(MPEGinfo, "Layer : ");
- lstrcat(MPEGinfo, maplay_args->MPEGheader->layer_string());
- lstrcat(MPEGinfo, "Checksums? : ");
- lstrcat(MPEGinfo, maplay_args->MPEGheader->checksums() ?
- "Yes" : "No");
- lstrcat(MPEGinfo, "\nMode : ");
- lstrcat(MPEGinfo, maplay_args->MPEGheader->mode_string());
- lstrcat(MPEGinfo, "Original? : ");
- lstrcat(MPEGinfo, maplay_args->MPEGheader->original() ?
- "Yes" : "No");
- lstrcat(MPEGinfo, "\nSample Frequency : ");
- lstrcat(MPEGinfo, maplay_args->MPEGheader->sample_frequency_string ());
- lstrcat(MPEGinfo, "Copyright? : ");
- lstrcat(MPEGinfo, maplay_args->MPEGheader->copyright() ?
- "Yes" : "No");
- lstrcat(MPEGinfo, "\nBitrate: ");
- lstrcat(MPEGinfo, maplay_args->MPEGheader->bitrate_string());
-
- lstrcat(MPEGinfo, "\n\nFrames : ");
- lstrcat(MPEGinfo, my_itoa(scroll_range, scratch, 10));
- lstrcat(MPEGinfo, "\nFile Size : ");
- lstrcat(MPEGinfo, my_itoa(maplay_args->stream->file_size() >> 10,
- scratch, 10));
- lstrcat(MPEGinfo, " KB");
-
- MessageBox(hWnd, MPEGinfo, "MPEG Properties", MB_OK | MB_ICONINFORMATION);
- return;
- }
-
- void about()
- {
- MessageBox(hWnd,
- "maplay 1.2+ for Win32 version 1.81 (04/19/97) - Pentium build.\n\n\
- A Full Quality MPEG-1 Audio (Layers I, II, & III) \
- Decoder for Windows 95 and NT.\n\
- Copyright ⌐ 1996, 1997 Jeff Tsay (ctsay@pasteur.eecs.berkeley.edu)\n\n\
- Based on maplay 1.2, Copyright ⌐ 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)\n\n\
- Layer III code adapted from the ISO MPEG Audio Subgroup Software Simulation \
- Group.\n\n\
- You may find information and the latest version at:\n\
- http://www-inst.eecs.berkeley.edu/~ctsay/mp2win32.html\n\n\
- Compiled with Borland C++ 5.01 courtesy of Borland International.\n\n\
- This program is free software. See the GNU General Public License in the file\n\
- COPYING for more details.",
- "About maplay 1.2+ for Win32", MB_OK);
- return;
- }
-
- #pragma argsused
- LRESULT APIENTRY SounderWndProc(HWND hWnd, UINT message,
- WPARAM wParam, LPARAM lParam)
- {
- BOOL disabled, selected;
- int32 new_pos;
-
- switch (message)
- {
- case WM_CREATE:
- openbut= CreateWindow ("BUTTON", NULL,
- WS_CHILD| WS_VISIBLE | WS_TABSTOP |
- BS_OWNERDRAW | BS_PUSHBUTTON,
- 5, 5, 24, 24,
- hWnd, (HMENU)CM_FILEOPEN, hInst, NULL);
-
- playbut= CreateWindow ("BUTTON", NULL,
- WS_CHILD | WS_VISIBLE | WS_DISABLED |
- WS_TABSTOP | BS_OWNERDRAW | BS_PUSHBUTTON,
- 45, 5, 24, 24,
- hWnd, (HMENU)CM_AUDIOPLAY, hInst,
- NULL);
-
- pausebut= CreateWindow ("BUTTON", NULL,
- WS_CHILD| WS_VISIBLE| WS_DISABLED |
- WS_TABSTOP | BS_OWNERDRAW | BS_PUSHBUTTON,
- 69, 5, 24, 24,
- hWnd, (HMENU)CM_AUDIOPAUSE, hInst, NULL);
-
- stopbut= CreateWindow ("BUTTON", NULL,
- WS_CHILD| WS_VISIBLE | WS_DISABLED |
- WS_TABSTOP | BS_OWNERDRAW | BS_PUSHBUTTON,
- 93, 5, 24, 24,
- hWnd, (HMENU)CM_AUDIOSTOP, hInst, NULL);
-
- rewbut= CreateWindow ("BUTTON", NULL,
- WS_CHILD| WS_VISIBLE | WS_DISABLED |
- WS_TABSTOP | BS_PUSHBUTTON | BS_OWNERDRAW,
- 157, 5, 24, 24,
- hWnd, (HMENU)CM_AUDIOREWIND, hInst, NULL);
-
- ffbut= CreateWindow ("BUTTON", NULL,
- WS_CHILD| WS_VISIBLE | WS_DISABLED |
- WS_TABSTOP | BS_PUSHBUTTON | BS_OWNERDRAW,
- 181, 5, 24, 24,
- hWnd, (HMENU)CM_AUDIOFAST_FORWARD, hInst, NULL);
-
- prevbut= CreateWindow ("BUTTON", NULL,
- WS_CHILD| WS_VISIBLE | WS_DISABLED |
- WS_TABSTOP | BS_PUSHBUTTON | BS_OWNERDRAW,
- 133, 5, 24, 24,
- hWnd, (HMENU)CM_LISTPREV, hInst, NULL);
-
- nextbut= CreateWindow ("BUTTON", NULL,
- WS_CHILD| WS_VISIBLE | WS_DISABLED |
- WS_TABSTOP | BS_PUSHBUTTON | BS_OWNERDRAW,
- 205, 5, 24, 24,
- hWnd, (HMENU)CM_LISTNEXT, hInst, NULL);
-
- aboutbut= CreateWindow ("BUTTON", NULL,
- WS_CHILD| WS_VISIBLE | WS_TABSTOP |
- BS_PUSHBUTTON | BS_OWNERDRAW,
- 245, 5, 24, 24,
- hWnd, (HMENU)CM_HELPABOUT, hInst, NULL);
-
- tracker= CreateWindow(TRACKBAR_CLASS, NULL,
- WS_CHILD | WS_VISIBLE | WS_TABSTOP |
- WS_DISABLED | TBS_AUTOTICKS,
- 5, 34, 263, 30, hWnd, (HMENU) 8, hInst, NULL);
-
- status_bar= CreateStatusWindow(WS_CHILD | WS_VISIBLE | SBT_NOBORDERS,
- "No file", hWnd, 0);
-
- SendMessage(status_bar, SB_SETPARTS, 4, (LPARAM) panes);
- return(DefWindowProc(hWnd, message, wParam, lParam));
-
- case WM_DRAWITEM:
- hdc = GetDC(hWnd);
- dis = (DRAWITEMSTRUCT *) lParam;
- disabled = (dis->itemState & ODS_DISABLED) == ODS_DISABLED;
- selected = (dis->itemState & ODS_SELECTED) == ODS_SELECTED;
-
- switch (dis->CtlType) {
-
- case ODT_BUTTON:
- if (dis->hwndItem == openbut)
- if (selected)
- DrawIcon(hdc, 5, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_9)));
- else
- DrawIcon(hdc, 5, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_12)));
- else if (dis->hwndItem == playbut)
- if (disabled)
- DrawIcon(hdc, 45, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_14)));
- else
- if (selected)
- DrawIcon(hdc, 45, 5, LoadIcon(hInst,MAKEINTRESOURCE(ICON_18)));
- else
- DrawIcon(hdc, 45, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_13)));
- else if (dis->hwndItem == pausebut)
- if (disabled)
- DrawIcon(hdc, 69, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_4)));
- else
- if (selected)
- DrawIcon(hdc, 69, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_24)));
- else
- DrawIcon(hdc, 69, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_6)));
- else if (dis->hwndItem == stopbut)
- if (disabled)
- DrawIcon(hdc, 93, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_3)));
- else
- if (selected)
- DrawIcon(hdc, 93, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_10)));
- else
- DrawIcon(hdc, 93, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_5)));
- else if (dis->hwndItem == aboutbut)
- if (selected)
- DrawIcon(hdc, 245, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_21)));
- else
- DrawIcon(hdc, 245, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_15)));
- else if (dis->hwndItem == rewbut)
- if (disabled)
- DrawIcon(hdc, 157, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_8)));
- else
- if (selected)
- DrawIcon(hdc, 157, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_22)));
- else
- DrawIcon(hdc, 157, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_7)));
- else if (dis->hwndItem == ffbut)
- if (disabled)
- DrawIcon(hdc, 181, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_17)));
- else
- if (selected)
- DrawIcon(hdc, 181, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_23)));
- else
- DrawIcon(hdc, 181, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_16)));
-
- else if (dis->hwndItem == prevbut)
- if (disabled)
- DrawIcon(hdc, 133, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_26)));
- else
- if (selected)
- DrawIcon(hdc, 133, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_27)));
- else
- DrawIcon(hdc, 133, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_20)));
- else if (dis->hwndItem == nextbut)
- if (disabled)
- DrawIcon(hdc, 205, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_29)));
- else
- if (selected)
- DrawIcon(hdc, 205, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_30)));
- else
- DrawIcon(hdc, 205, 5, LoadIcon(hInst, MAKEINTRESOURCE(ICON_28)));
- break;
- }
-
- ReleaseDC(hWnd, hdc);
- return(DefWindowProc(hWnd, message, wParam, lParam));
-
- case WM_COMMAND:
- switch (GET_WM_COMMAND_ID(wParam, lParam))
- {
- case CM_FILEOPEN:
- file_open();
- break;
-
- case CM_FILEEXIT:
- leave();
- break;
-
- case CM_AUDIOPLAY:
- audio_play();
- break;
-
- case CM_AUDIOPAUSE:
- audio_pause();
- break;
-
- case CM_AUDIOSTOP:
- audio_stop();
- break;
-
- case CM_AUDIOREWIND:
- CMDLINE = FALSE;
- scrolling = TRUE;
-
- new_pos = SendMessage(tracker, TBM_GETPOS, 0, 0);
- if ((new_pos -= line_size) < 0)
- new_pos = 0;
-
- WaitForSingleObject(args->mutex, INFINITE);
- args->desired_position = new_pos;
-
- if (!args->position_change) {
- args->position_change = TRUE;
- if (!paused && playing)
- PostMessage(status_bar,SB_SETTEXT, 0,
- (LPARAM) "Seeking...");
- }
- ReleaseMutex(args->mutex);
-
- SendMessage(tracker, TBM_SETPOS, (WPARAM) TRUE, new_pos);
- break;
-
- case CM_AUDIOFAST_FORWARD:
- CMDLINE = FALSE;
-
- new_pos = SendMessage(tracker, TBM_GETPOS, 0, 0);
- if ((new_pos += line_size) < scroll_range) {
-
- scrolling = TRUE;
- WaitForSingleObject(args->mutex, INFINITE);
- args->desired_position = new_pos;
- scrolling = TRUE;
-
- if (!args->position_change) {
- args->position_change = TRUE;
-
- if (!paused && playing)
- PostMessage(status_bar,SB_SETTEXT, 0,
- (LPARAM) "Seeking...");
- }
- ReleaseMutex(args->mutex);
-
- SendMessage(tracker, TBM_SETPOS, (WPARAM) TRUE, new_pos);
- }
- break;
-
-
- case CM_AUDIOREPEAT:
- CMDLINE = FALSE;
- // Beautiful C++ style, but Borland doesn't like this:
-
- if (Repeat = !Repeat) {
- CheckMenuItem(mainmenu, CM_AUDIOREPEAT, MF_CHECKED);
- SendMessage(status_bar,SB_SETTEXT, 3,(LPARAM) "R");
- } else {
- CheckMenuItem(mainmenu, CM_AUDIOREPEAT, MF_UNCHECKED);
- SendMessage(status_bar,SB_SETTEXT, 3,(LPARAM) "");
- }
- break;
-
- case CM_OPTIONS:
- if (DialogBox(hInst, MAKEINTRESOURCE(OPTIONS), hWnd,
- Options) == -1)
- MessageBox(hWnd, "Unable to open options dialog box.",
- "Error Opening Dialog Box", MB_OK);
- break;
-
- case CM_AUDIOPROPERTIES:
- audio_properties();
- break;
-
- case CM_LISTPREV:
- gotop_List(-2);
- break;
-
- case CM_LISTREPEAT:
- gotop_List(-1);
- break;
-
- case CM_LISTNEXT:
- gotop_List(0);
- break;
-
- case CM_HELPABOUT:
- about();
- break;
-
- default:
- break;
- }
- break;
-
- case WM_HSCROLL:
- // Process scroll messages by sending notification to
- // appropriate thread.
- LRESULT new_pos;
-
- switch (LOWORD(wParam)) {
- case TB_LINEUP:
- case TB_LINEDOWN:
- case TB_PAGEDOWN:
- case TB_PAGEUP:
- CMDLINE = FALSE;
- new_pos = SendMessage(tracker, TBM_GETPOS, 0, 0);
-
- if ((new_pos <= scroll_range) && (new_pos >= 0)) {
- scrolling = TRUE;
- WaitForSingleObject(args->mutex, INFINITE);
- args->desired_position = new_pos;
-
- if (!args->position_change) {
- args->position_change = TRUE;
- if (!paused && playing)
- SendMessage(status_bar,SB_SETTEXT, 0,
- (LPARAM) "Seeking...");
- }
- ReleaseMutex(args->mutex);
- }
- break;
-
- case TB_THUMBTRACK:
- scrolling = TRUE; // We are scrolling, don't allow
- // scroll position changes by threads.
- new_pos = SendMessage(tracker, TBM_GETPOS, 0, 0);
- update_timewin((int32) new_pos);
- break;
-
- case TB_THUMBPOSITION: // Scroll box placed somewhere
- WaitForSingleObject(args->mutex, INFINITE);
- args->desired_position = SendMessage(tracker, TBM_GETPOS, 0, 0);
-
- if(!args->position_change) {
- args->position_change = TRUE;
- if (!paused && playing)
- SendMessage(status_bar,SB_SETTEXT, 0,
- (LPARAM) "Seeking...");
- }
- ReleaseMutex(args->mutex);
- break;
- }
- return(0);
-
- case SCROLL_POS: // Process new position data from threads.
- if (!scrolling && (wParam <=scroll_range) && playing) {
- SendMessage(tracker, TBM_SETPOS, TRUE, wParam);
- update_timewin((int32) wParam);
- }
- return(0);
-
- case SEEK_ACK: // Seek completed, allow scroll changes.
- if (playing) {
- SendMessage(status_bar, SB_SETTEXT, 0, (LPARAM) "Playing...");
- scrolling = FALSE;
- }
- return(0);
-
- case MM_MCINOTIFY:
- switch (wParam) {
- case MCI_NOTIFY_SUCCESSFUL:
- clear_sound();
-
- if (ListMode) {
- Next_Song();
- return(0);
- }
-
- reinit_MCI();
- ok_play();
- no_stop();
-
- if (Repeat) {
- no_play();
- MCI_play();
- SendMessage(status_bar, SB_SETTEXT, 0, (LPARAM) "Playing...");
- } else {
- playing=FALSE;
- if (CMDLINE)
- leave();
- SendMessage(status_bar, SB_SETTEXT, 0, (LPARAM) "Stopped");
- }
- break;
- }
- break;
-
- case WM_DROPFILES:
- CMDLINE = FALSE;
-
- DragAcceptFiles(hWnd, TRUE);
- DragQueryFile((HDROP) wParam, 0, szName, MAX_PATH);
- DragFinish((HDROP) wParam);
-
- if (file_load())
- audio_play();
- break;
-
- case WM_DESTROY:
- PostQuitMessage(0); // this is the end...
- break;
-
- case WM_CLOSE:
- // Tell windows to destroy our window.
- leave();
- break;
-
- case WM_THREADEND:
- clear_sound();
-
- if (ListMode) {
- Next_Song();
- return(0);
- }
-
- if (CMDLINE)
- leave();
- else {
- playing = FALSE;
- reinit_MPEG(); // We know file is ok already.
-
- if (Repeat) {
- MPEG_play();
- SendMessage(status_bar,SB_SETTEXT, 0,(LPARAM) "Playing...");
- } else {
- ok_play();
- no_stop();
- SendMessage(status_bar,SB_SETTEXT, 0,(LPARAM) "Stopped");
- }
- }
- break;
-
- case WM_CMDLINEFILE:
- lstrcpy(szName, (LPSTR) lParam);
-
- if (wParam == 2) {
-
- ListMode = TRUE;
- Init_List();
- Get_File_List(szName);
- DisplayName(szName);
- lstrcpy(szName, PlayList[0]);
- File_Init();
- ok_play();
- audio_play();
-
- } else {
-
- if (wParam == 0) {
- playing=TRUE;
- no_play();
- reinit_MCI();
- MCI_play();
- } else {
- clear_sound();
- if (!reinit_MPEG())
- return(1);
- playing=FALSE;
- no_play();
- MPEG_play();
- }
- SendMessage(status_bar,SB_SETTEXT, 0,(LPARAM) "Playing...");
- DisplayName(szName);
- }
-
-
- EnableWindow(rewbut, TRUE);
- EnableMenuItem(mainmenu, CM_AUDIOREWIND, MF_ENABLED);
- EnableWindow(ffbut, TRUE);
- EnableMenuItem(mainmenu, CM_AUDIOFAST_FORWARD, MF_ENABLED);
- break;
-
- case WM_CHAR:
- switch(wParam) {
- case 'o':
- file_open();
- break;
-
- case ' ':
- audio_play();
- break;
-
- case 's':
- audio_stop();
- break;
-
- case '"':
- case 'p':
- audio_pause();
- break;
-
- case '?':
- about();
- break;
-
- case 'x':
- case 'q':
- leave();
- break;
- }
- break;
-
- case 312: // CTLCOLOR message for trackbar
- if ((HWND) lParam == tracker)
- return((DWORD) GetStockObject(LTGRAY_BRUSH));
-
- default:
- // Let windows handle all messages we choose to ignore.
- return(DefWindowProc(hWnd, message, wParam, lParam));
- }
- return(0);
- }
-
- void leave_options(HWND hDlg, BOOL save)
- {
- enum e_channels new_mode;
-
- if (save) {
-
-
- if (IsDlgButtonChecked(hDlg, IDC_STEREO))
- new_mode = both;
- else if (IsDlgButtonChecked(hDlg, IDC_LEFT))
- new_mode = left;
- else if (IsDlgButtonChecked(hDlg, IDC_RIGHT))
- new_mode = right;
- else
- new_mode = downmix;
-
- if (mode != new_mode) {
-
- if (!(playing || paused)) {
-
- mode = new_mode;
- reinit_MPEG();
-
- } else {
- MessageBox(hDlg, "You must stop the stream before modifying the \
- decoding options.", "Options error", MB_ICONEXCLAMATION | MB_OK);
- }
- }
- }
-
- EndDialog(hDlg, TRUE);
-
- return;
- }
-
- #pragma argsused
- BOOL WINAPI Options(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message) {
-
- case WM_INITDIALOG:
-
- switch (mode) {
- case both:
- CheckRadioButton(hDlg, IDC_STEREO, IDC_DOWNMIX, IDC_STEREO);
- break;
-
- case left:
- CheckRadioButton(hDlg, IDC_STEREO, IDC_DOWNMIX, IDC_LEFT);
- break;
-
- case right:
- CheckRadioButton(hDlg, IDC_STEREO, IDC_DOWNMIX, IDC_RIGHT);
- break;
-
- case downmix:
- CheckRadioButton(hDlg, IDC_STEREO, IDC_DOWNMIX, IDC_DOWNMIX);
- break;
- }
- return(TRUE);
-
- case WM_CLOSE:
- leave_options(hDlg, TRUE);
- return(TRUE);
-
- case WM_COMMAND:
- {
- switch (GET_WM_COMMAND_ID(wParam, lParam)) {
-
- case IDC_STEREO:
- CheckRadioButton(hDlg, IDC_STEREO, IDC_DOWNMIX, IDC_STEREO);
- return(TRUE);
-
- case IDC_LEFT:
- CheckRadioButton(hDlg, IDC_STEREO, IDC_DOWNMIX, IDC_LEFT);
- return(TRUE);
-
- case IDC_RIGHT:
- CheckRadioButton(hDlg, IDC_STEREO, IDC_DOWNMIX, IDC_RIGHT);
- return(TRUE);
-
- case IDC_DOWNMIX:
- CheckRadioButton(hDlg, IDC_STEREO, IDC_DOWNMIX, IDC_DOWNMIX);
- return(TRUE);
-
- case IDOK:
- leave_options(hDlg, TRUE);
- return(TRUE);
-
- case IDCANCEL:
- leave_options(hDlg, FALSE);
-
- default:
- return(FALSE);
- }
- }
-
- default:
- return(FALSE);
- }
- }
-
-